<%@ page import="java.util.Date" %><%--
  Created by IntelliJ IDEA.
  User: sun
  Date: 2020/5/8
  Time: 10:55 上午
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>$Title$</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.0/jquery.min.js"></script>
</head>
<body>
<%=new Date()%><br/>
<a href="#" class="getEmps"> GetAllEmpolyee</a><br/>
<div></div>
<script type="text/javascript">
$(function () {
    $("a.getEmps").click(function () {
        //发送ajax请求
        $.ajax({
            url:"${pageContext.request.contextPath}/empsAjax",
            type:"get",
            success:function (data) {
                $.each(data,function () {
                    const empinfo=this.lastName+"--->"+this.birth+"--->"+this.gender;
                    $("div").append(empinfo+"<br/>");
                })
            }
        });

        return false;
    })
})

</script>

<form action="${pageContext.request.contextPath}/httpEntity" method="post" enctype="multipart/form-data" >
    <input name="username" value="tomcat"/><br/>
    <input name="password" value="123456"/><br/>
    <input name="file" type="file"/><br/>
    <input type="submit" value="submit">
</form>

<a href="#" class="json">发送Json数据 </a>
<script type="text/javascript">
    $(function () {
        const emp={
            id:1005,
            lastName:"sun",
            email:"aaa.@aa.com"
        };
        $("a.json").click(function () {
            $.ajax({
                url:"${pageContext.request.contextPath}/requestJson",
                type: "post",
                data:JSON.stringify(emp),
                contentType:"application/json",
                success:function (data) {

                }
            })
        })
    })
</script>
<br/>
<a href="${pageContext.request.contextPath}/responseEntity">responseEntity</a>
<br/>
<a href="${pageContext.request.contextPath}/showDownFiles">展示下载文件列表</a>
<h1>表单文件上传</h1>
<h3>单文件</h3>
<form action="${pageContext.request.contextPath}/uploadFile" enctype="multipart/form-data" method="post">
    上传头像：<input name="headImg" type="file"/><br/>
    用户名：<input type="text" name="usename" value="sun"><br/>
    <input value="submit" type="submit">
</form>

<h3>多文件</h3>
<form action="${pageContext.request.contextPath}/multiUploadFile" enctype="multipart/form-data" method="post">
    上传头像：<input name="headImg" type="file"/><br/>
    上传文档：<input name="headImg" type="file"/><br/>
    用户名：<input type="text" name="usename" value="sun"><br/>
    <input value="submit" type="submit">
</form>
</body>
</html>
